<template>
  <d2-container>

    <demo-page-header slot="header" @submit="handleSubmit" ref="header" />
    <demo-page-main :table-data="table" :loading="loading" />
    <demo-page-dialg ref="dialg01"></demo-page-dialg>
  </d2-container>
</template>

<script>
  import {
    BusinessTable1List
  } from '@api/demo.business.table.1'
  export default {
    // name 值和本页的 $route.name 一致才可以缓存页面
    name: 'demo-business-table-1',
    components: {
      'DemoPageHeader': () => import('./componnets/PageHeader'),
      'DemoPageMain': () => import('./componnets/PageMain'),
      'DemoPageDialg': () => import('./componnets/PageDialg')
    },
    
    data() {
      return {
        table: [],
        loading: false,
      }
    },
    methods: {
      handleSubmit(form) {
        this.loading = true
        BusinessTable1List({
            ...form
          })
          .then(res => {
            this.loading = false
            // console.log(res)
            if (res.flag) {
              this.table = res.results.data
            }
            this.$notify({
              title: '数据请求完毕'
            })
          })
          .catch(err => {
            this.loading = false
            this.$notify({
              title: '数据请求异常'
            })
            console.log('err', err)
          })
      }
    }
  }
</script>
